//无法调整新增备份时间，未报错
//无法删除机器人正则，未报错
import {
    ll,
    mc,
    Format,
    PermType,
    system,
    logger,
    File,
    JsonConfigFile,
    WSClient,
    colorLog,
    log,
    NbtEnd,
    NbtShort,
    NbtInt,
    NbtFloat,
    NbtDouble,
    NbtCompound,
    NbtList,
    NbtLong,
    NbtByte,
    NbtByteArray,
    NbtString,
    NBT
} from '@LiteLoaderLibs/index.js'
import { PowerNukkitX, EventPriority } from ":powernukkitx";
let robotConf,robotReg, robotCmd,conf,bk;
export function main(){
    //console.log("加载");
    PowerNukkitX.listenEvent("cn.nukkit.event.server.ServerStartedEvent",EventPriority.NORMAL, event => { 
        detect();
    })
}
function detect(){
    if(File.exists("DLS")&&File.checkIsDir("DLS")){
        if(File.exists("DLS/机器人命令.json")&&File.exists("DLS/机器人配置.json")&&File.exists("DLS/机器人正则.json")&&File.exists("DLS/配置.json")&&File.exists("DLS/备份.json")){
            old_main();
        }
        else{
            logger.info("DLS/中的文件不完整。")
            logger.info("EditDLSConfig已退出");
            //error
        }
    }
    else{
        //logger.info("退出")//没有error
        logger.info("找不到或无法访问/DLS。这可能是因为DLS未安装，或未正确配置。")
        logger.info("EditDLSConfig已退出");
    }    
}
function old_main(){
    let maincmd=mc.newCommand("dlsconfig", "编辑DLS的配置文件");
    maincmd.overload([]);
    maincmd.setCallback((cmd, origin, output, results) => {
        mainmenu(origin.player);
    })
    maincmd.setup();
}
function mainmenu(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("选择一个配置文件");
    fm.addButton("快捷操作");
    fm.addButton("机器人配置.json");
    fm.addButton("机器人正则.json");
    fm.addButton("机器人命令.json");
    fm.addButton("配置.json");
    fm.addButton("备份.json");
    player.sendForm(fm,(player,id)=>{
        switch(id){
            case 0:{
                shortcut(player);
                break;
            }
            case 1:{
                editRobotConf(player);
                break;
            }
            case 2:{
                editRobotReg(player);
                break;
            }
            case 3:{
                editRobotCmd(player);
                break;
            }
            case 4:{
                editConf(player);
                break;
            }
            case 5:{
                editBk(player);
                break;
            }
            default:{
                log("dlsload")
            }
        }
    })
}
function shortcut(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("快捷操作");
    fm.addButton("输出屏蔽");
    fm.addButton("QQ群管理员");
    fm.addButton("备份");
    player.sendForm(fm,(player,id)=>{
        switch(id){
            case 0:{
                outputFilter(player);
                break;
            }
            case 1:{
                qqAdministrators(player);
                break;
            }
            case 2:{
                bkSettings(player);
                break;
            }
            default:{
                mainmenu(player);
            }    
        }

    })
}
function outputFilter(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("输出屏蔽");   
    fm.addButton("添加正则");
    fm.addButton("删除正则");    
    let regs=JSON.parse(File.readFrom("DLS/配置.json")).输出屏蔽;
    regs.forEach((currentValue)=>{
        fm.addButton(currentValue);
    })
    player.sendForm(fm,(player,id)=>{
        if(id==null){
            shortcut(player);
        }
        else if(id===0){
            newOutputFilter(player);
        }
        else if(id===1){
            delOutputFilter(player);
        }
        else{
            editDedicatedOutputFilter(player,id-2);
        }
    })
}
function editDedicatedOutputFilter(player,index){
    let regs=JSON.parse(File.readFrom("DLS/配置.json")).输出屏蔽;
    let fm=mc.newCustomForm();
    fm.setTitle("编辑输出屏蔽正则");
    fm.addInput("正则"," ",regs[index]);
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/配置.json"));
            write.输出屏蔽[index]=data[0];
            File.writeTo("DLS/配置.json",JSON.stringify(write,null,4));
        }
       outputFilter(player);
    })    
}
function newOutputFilter(player){
    let i;
    let fm=mc.newCustomForm();
    fm.setTitle("添加新正则");
    fm.addInput("正则");
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/配置.json"));
            let error=[false],errors=false;
            let newReg=""
            if(data[0]===""){
                error[0]=true;
            }
            else{
                newReg=data[0];
            }
            write.输出屏蔽.push(newReg);
            for(i=0;i<error.length;i++){
                if(error[i]!==false){
                    let errortext="以下参数不正确\n";
                    if(error[0]){
                        errortext=errortext+"正则不能为空\n";
                    }
                    player.sendModalForm("参数错误",errortext,"继续","继续",(player,result)=>{
                        newOutputFilter(player);
                    })
                    errors=true;
                    break;
                }
            }
            if(!errors){
                File.writeTo("DLS/配置.json",JSON.stringify(write,null,4));
                outputFilter(player);
            }
        }
        else{
            outputFilter(player);
        }
        
    })
}
function delOutputFilter(player){
    let i;
    let fm=mc.newSimpleForm();
    fm.setTitle("删除正则");
    fm.setContent("以下是已添加的正则");
    for(i=0;i<JSON.parse(File.readFrom("DLS/配置.json")).输出屏蔽.length;i++){
        fm.addButton(JSON.parse(File.readFrom("DLS/配置.json")).输出屏蔽[i]);
    }
    player.sendForm(fm,(player,id)=>{
        if(id!=null){
            let write=JSON.parse(File.readFrom("DLS/配置.json"));
            write.输出屏蔽.splice(id,1);
            File.writeTo("DLS/配置.json",JSON.stringify(write,null,4));
        }
       outputFilter(player);
    })
}
function qqAdministrators(player){
    let fm=mc.newSimpleForm();
    let content="以下是已添加的管理员：\n";
    JSON.parse(File.readFrom("DLS/机器人配置.json")).管理员QQ号.forEach((currentValue)=>{
        content=content+currentValue.toString()+"\n"
    })
    fm.setTitle("管理QQ群管理员");  
    fm.setContent(content); 
    fm.addButton("添加管理员");
    fm.addButton("删除管理员");    
    player.sendForm(fm,(player,id)=>{
        if(id===0){
            newAdministrator(player);
        }
        else if(id===1){
            delAdministrator(player);
        }
        else{
            shortcut(player);
        }
    })
}
function newAdministrator(player){
    let i;
    let fm=mc.newCustomForm();
    fm.setTitle("添加管理员");
    fm.addInput("管理员的QQ号");
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人配置.json"));
            let error=[""],errors=false;
            let Administrator=""
            if(data[0]===""){
                error[0]="empty";
            }
            else if(!Number.isSafeInteger(Number(data[0]))){
                error[0]="notsafe";
            }
            else{
                Administrator=Number(data[0]);
            }
            write.管理员QQ号.push(Administrator);
            for(i=0;i<error.length;i++){
                if(error[i]!==""){
                    let errortext="以下参数不正确\n";
                    if(error[0]==="empty"){
                        errortext=errortext+"管理员QQ号不能为空\n";
                    }
                    else if(error[0]==="notsafe"){
                        errortext=errortext+"管理员QQ号格式不正确\n";
                    }
                    player.sendModalForm("参数错误",errortext,"继续","继续",(player,result)=>{
                        newAdministrator(player);
                    })
                    errors=true;
                    break;
                }
            }
            if(!errors){
                File.writeTo("DLS/机器人配置.json",JSON.stringify(write,null,4));
                qqAdministrators(player);
            }
        }
        else{
            qqAdministrators(player);
        }
        
    })
}
function delAdministrator(player){
    let i;
    let fm=mc.newSimpleForm();
    fm.setTitle("删除管理员");
    fm.setContent("以下是已添加的管理员");
    for(i=0;i<JSON.parse(File.readFrom("DLS/机器人配置.json")).管理员QQ号.length;i++){
        fm.addButton(JSON.parse(File.readFrom("DLS/机器人配置.json")).管理员QQ号[i].toString());
    }
    player.sendForm(fm,(player,id)=>{
        if(id!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人配置.json"));
            write.管理员QQ号.splice(id,1);
            File.writeTo("DLS/机器人配置.json",JSON.stringify(write,null,4));
        }
       qqAdministrators(player);
    })
}
function bkSettings(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("备份设置");
    fm.addButton("选择周备份日");
    fm.addButton("管理备份时间");
    player.sendForm(fm,(player,id)=>{
        switch(id){
            case 0:{
                chooseBkDay(player);
                break;
            }
            case 1:{
                mgbktime(player);
                break;
            }
            default:{
                shortcut(player);
            }
        }
    })
}
function chooseBkDay(player){
    let fm=mc.newCustomForm();
    fm.setTitle("选择要备份的日期");
    for(let i=1;i<=7;i++){
        if(JSON.parse(File.readFrom("DLS/备份.json")).周备份日.includes(i)){
            fm.addSwitch(i.toString(),true);
        }
        else{
            fm.addSwitch(i.toString(),false);
        }
    }
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let bkday=[];
            data.forEach((currentValue,index)=>{
                if(currentValue){
                    bkday.push(index+1);
                }
            })
            let write=JSON.parse(File.readFrom("DLS/备份.json"));
            write.周备份日=bkday;
            File.writeTo("DLS/备份.json",JSON.stringify(write,null,4));            
        }
        bkSettings(player);
    })
}
function mgbktime(player){
    let fm=mc.newSimpleForm();
    let content="以下是已添加的备份时间：\n";
    JSON.parse(File.readFrom("DLS/备份.json")).备份时间.forEach((currentValue)=>{
        content=content+currentValue+"\n"
    })
    fm.setTitle("管理备份时间");  
    fm.setContent(content); 
    fm.addButton("添加备份时间");
    fm.addButton("删除备份时间");    
    player.sendForm(fm,(player,id)=>{
        if(id===0){
            newbktime(player);
        }
        else if(id===1){
            delbktime(player);
        }
        else{
            bkSettings(player);
        }
    })
}
function newbktime(player){
    let fm=mc.newCustomForm();
    fm.setTitle("选择一个新的备份时间");
    fm.addSlider("小时",0,23);
    fm.addSlider("分钟",0,59);
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/备份.json"));
            write.备份时间.push(data[0].toString()+":"+data[1].toString());
            File.writeTo("DLS/备份.json",JSON.stringify(write,null,4));  
        }
        mgbktime(player);
    })
}
function delbktime(player){
    let i;
    let fm=mc.newSimpleForm();
    fm.setTitle("删除备份时间");
    fm.setContent("以下是已添加的备份时间");
    for(i=0;i<JSON.parse(File.readFrom("DLS/备份.json")).备份时间.length;i++){
        fm.addButton(JSON.parse(File.readFrom("DLS/备份.json")).备份时间[i].toString());
    }
    player.sendForm(fm,(player,id)=>{
        if(id!=null){
            let write=JSON.parse(File.readFrom("DLS/备份.json"));
            write.备份时间.splice(id,1);
            File.writeTo("DLS/备份.json",JSON.stringify(write,null,4));
        }
        mgbktime(player);
    })
}
function mgrbkpath(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("选择备份路径");
}
function editRobotConf(player){
    let fm=mc.newCustomForm();
    let access_token=File.readFrom("DLS/机器人配置.json").match(/"access-token": "(.+?)"/)[1];
    fm.setTitle("编辑机器人配置.json")
    fm.addSwitch("启用机器人",JSON.parse(File.readFrom("DLS/机器人配置.json")).启用机器人);
    fm.addInput("机器人地址"," ",JSON.parse(File.readFrom("DLS/机器人配置.json")).机器人地址);
    fm.addInput("机器人端口"," ",JSON.parse(File.readFrom("DLS/机器人配置.json")).机器人端口.toString());
    fm.addInput("access-token"," ",access_token);
    fm.addInput("管理QQ群号"," ",JSON.parse(File.readFrom("DLS/机器人配置.json")).管理QQ群号.toString());
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write = JSON.parse(File.readFrom("DLS/机器人配置.json"))
            write.启用机器人=data[0];
            write.机器人地址=data[1];
            write.机器人端口=Number(data[2]);
            write.管理QQ群号=Number(data[4]);
            File.writeTo("DLS/机器人配置.json",JSON.stringify(write,null,4).replace("\"access-token\": \""+access_token+"\"","\"access-token\": \""+data[3]+"\""));
        }
        mainmenu(player);
    })
}
function editRobotReg(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("编辑机器人正则.json")
    fm.setContent("以下是所有正则匹配的返回消息格式");
    fm.addButton("添加正则");
    fm.addButton("删除正则");
    let regs=JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配;
    regs.forEach((currentValue)=>{
        if(currentValue.返回消息格式!=null){fm.addButton(currentValue.返回消息格式);}
        else if(currentValue.执行命令!=null){fm.addButton(currentValue.执行命令);}
        else{fm.addButton(currentValue.正则);}
    })
    player.sendForm(fm,(player,id)=>{
        if(id==null){
            mainmenu(player);
        }
        else if(id===0){
            newRobotReg(player);
        }
        else if(id===1){
            delRobotReg(player);
        }
        else{
            editRobotDedicatedReg(player,id-2);
        }
    })
}
function editRobotDedicatedReg(player,index){
    let regs=JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配;
    let fm=mc.newCustomForm();
    let availablekeys=[];
    if(regs[index].正则!=null){availablekeys.push("正则");fm.addInput("正则"," ",regs[index].正则);}
    if(regs[index].返回消息格式!=null){availablekeys.push("返回消息格式");fm.addInput("返回消息格式"," ",regs[index].返回消息格式);}
    if(regs[index].执行命令!=null){availablekeys.push("执行命令");fm.addInput("执行命令"," ",regs[index].执行命令);}
    fm.setTitle("编辑正则");
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人正则.json"));
            availablekeys.forEach((currentValue,index1)=>{
                if(currentValue==="正则"){
                    write.正则匹配[index].正则=data[index1]
                }
                else if(currentValue==="返回消息格式"){
                    write.正则匹配[index].返回消息格式=data[index1]
                }
                else if(currentValue==="执行命令"){
                    write.正则匹配[index].执行命令=data[index1]
                }
            })
            File.writeTo("DLS/机器人正则.json",JSON.stringify(write,null,4));
        }
        editRobotReg(player);
    })
}
function newRobotReg(player){
    let i;
    let fm=mc.newCustomForm();
    fm.setTitle("添加新正则");
    fm.addInput("正则");
    fm.addInput("执行命令");
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人正则.json"));
            let error=[false,false],errors=false;
            let newReg={
                正则:"",
                执行命令:""
            };
            if(data[0]===""){
                error[0]=true;
            }
            else{
                newReg.正则=data[0];
            }
            if(data[1]===""){
                error[1]=true;
            }
            else{
                newReg.执行命令=data[1];
            }
            write.正则匹配.push(newReg);
            for(i=0;i<error.length;i++){
                if(error[i]!==false){
                    let errortext="以下参数不正确\n";
                    if(error[0]){
                        errortext=errortext+"正则不能为空\n";
                    }
                    if(error[1]){
                        errortext=errortext+"执行命令不能为空\n";
                    }
                    player.sendModalForm("参数错误",errortext,"继续","继续",(player,result)=>{
                        newRobotReg(player);
                    })
                    errors=true;
                    break;
                }
            }
            if(!errors){
                File.writeTo("DLS/机器人正则.json",JSON.stringify(write,null,4));
                editRobotReg(player);
            }
        }
        else{
            editRobotReg(player);
        }
        
    })
}
function delRobotReg(player){
    /*
    打不开，提示
    Received invalid form json. 
    Error:/buttons/0: Could not find required property 'text'
    */
    let i;
    let fm=mc.newSimpleForm();
    fm.setTitle("删除正则");
    fm.setContent("以下是已添加的正则");
    for(i=0;i<JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配.length;i++){
        if(JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配[i].返回消息格式!=null){fm.addButton(JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配[i].返回消息格式);}//llse那边也要改
        if(JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配[i].执行命令!=null){fm.addButton(JSON.parse(File.readFrom("DLS/机器人正则.json")).正则匹配[i].执行命令);}
    }
    //目前可以确定问题出在被注释的部分
    player.sendForm(fm,(player,id)=>{
        if(id!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人正则.json"));
            write.正则匹配.splice(id,1);
            File.writeTo("DLS/机器人正则.json",JSON.stringify(write,null,4));
        }
        editRobotReg(player);
    })
}
function editRobotCmd(player){
    let fm=mc.newSimpleForm();
    fm.setTitle("编辑机器人命令.json")
    fm.setContent("以下是所有识别头");
    fm.addButton("添加命令");
    fm.addButton("删除命令");
    let cmds=JSON.parse(File.readFrom("DLS/机器人命令.json")).群自定义命令;
    cmds.forEach((currentValue)=>{
        fm.addButton(currentValue.识别头);
    })
    player.sendForm(fm,(player,id)=>{
        if(id==null){
            mainmenu(player);
        }
        else if(id===0){
            newRobotCmd(player);
        }
        else if(id===1){
            delRobotCmd(player);
        }
        else{
            editRobotDedicatedCmd(player,id-2);
        }
    })
}
function editRobotDedicatedCmd(player,index){
    let cmds=JSON.parse(File.readFrom("DLS/机器人命令.json")).群自定义命令;
    let fm=mc.newCustomForm();
    let availablekeys=[];
    if(cmds[index].识别头!=null){availablekeys.push("识别头");fm.addInput("识别头"," ",cmds[index].识别头);}
    if(cmds[index].执行命令!=null){availablekeys.push("执行命令");fm.addInput("执行命令"," ",cmds[index].执行命令);}
    if(cmds[index].记录!=null){availablekeys.push("记录");fm.addInput("记录"," ",cmds[index].记录);}
    if(cmds[index].限制次数!=null){availablekeys.push("限制次数");fm.addInput("限制次数"," ",cmds[index].限制次数.toString());}
    if(cmds[index].全员可用!=null){availablekeys.push("全员可用");fm.addSwitch("全员可用",cmds[index].全员可用);}
    if(cmds[index].退群重置!=null){availablekeys.push("退群重置");fm.addSwitch("退群重置",cmds[index].退群重置);}
    if(cmds[index].退群触发!=null){availablekeys.push("退群触发");fm.addInput("退群触发"," ",cmds[index].退群触发);}
    fm.setTitle("编辑命令");
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人命令.json"));
            availablekeys.forEach((currentValue,index1)=>{
                if(currentValue==="识别头"){write.群自定义命令[index].识别头=data[index1]}
                else if(currentValue==="执行命令"){write.群自定义命令[index].执行命令=data[index1]}
                else if(currentValue==="记录"){ write.群自定义命令[index].记录=data[index1]}
                else if(currentValue==="限制次数"){write.群自定义命令[index].限制次数=Number(data[index1])}
                else if(currentValue==="全员可用"){write.群自定义命令[index].全员可用=data[index1]}
                else if(currentValue==="退群重置"){write.群自定义命令[index].退群重置=data[index1]}
                else if(currentValue==="退群触发"){write.群自定义命令[index].退群触发=data[index1]}
            })
            File.writeTo("DLS/机器人命令.json",JSON.stringify(write,null,4));
        }
        editRobotCmd(player);
    })
}
function newRobotCmd(player){
    let i;
    let fm=mc.newCustomForm();
    fm.setTitle("添加新命令");
    fm.addInput("识别头");
    fm.addInput("执行命令");
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人命令.json"));
            let error=[false,false],errors=false;
            let newCmd={
                识别头:"",
                执行命令:""
            };
            if(data[0]===""){
                error[0]=true;
            }
            else{
                newCmd.识别头=data[0];
            }
            if(data[1]===""){
                error[1]=true;
            }
            else{
                newCmd.执行命令=data[1];
            }
            write.群自定义命令.push(newCmd);
            for(i=0;i<error.length;i++){
                if(error[i]!==false){
                    let errortext="以下参数不正确\n";
                    if(error[0]){
                        errortext=errortext+"识别头不能为空\n";
                    }
                    if(error[1]){
                        errortext=errortext+"执行命令不能为空\n";
                    }
                    player.sendModalForm("参数错误",errortext,"继续","继续",(player,result)=>{
                        newRobotCmd(player);
                    })
                    errors=true;
                    break;
                }
            }
            if(!errors){
                File.writeTo("DLS/机器人命令.json",JSON.stringify(write,null,4));
                editRobotCmd(player);
            }
        }
        else{
            editRobotCmd(player);
        }
        
    })
}
function delRobotCmd(player){
    let i;
    let fm=mc.newSimpleForm();
    fm.setTitle("删除命令");
    fm.setContent("以下是已添加的命令");
    for(i=0;i<JSON.parse(File.readFrom("DLS/机器人命令.json")).群自定义命令.length;i++){
        fm.addButton(JSON.parse(File.readFrom("DLS/机器人命令.json")).群自定义命令[i].识别头);
    }
    player.sendForm(fm,(player,id)=>{
        if(id!=null){
            let write=JSON.parse(File.readFrom("DLS/机器人命令.json"));
            write.群自定义命令.splice(id,1);
            File.writeTo("DLS/机器人命令.json",JSON.stringify(write,null,4));
        }
        editRobotCmd(player);
    })
}
function editConf(player){
    let fm=mc.newCustomForm();
    fm.setTitle("编辑配置.json")
    fm.addInput("开服命令"," ",JSON.parse(File.readFrom("DLS/配置.json")).开服命令);
    fm.addSwitch("崩溃重启",JSON.parse(File.readFrom("DLS/配置.json")).崩溃重启);
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write = JSON.parse(File.readFrom("DLS/配置.json"))
            write.开服命令=data[0];
            write.崩溃重启=data[1];
            File.writeTo("DLS/配置.json",JSON.stringify(write,null,4));
        }
        mainmenu(player);
    })   
}
function editBk(player){
    let z7=false;
    if(File.readFrom("DLS/备份.json").match(/"7z压缩": (.+?)/)!=null){
        z7=JSON.parse("{\"a\": "+File.readFrom("DLS/备份.json").match(/"7z压缩": (.+?)[,|}]/s)[1].replace("\n","")+"}").a;
    }
    let fm=mc.newCustomForm();
    fm.setTitle("编辑备份.json")
    fm.addSwitch("自动备份",JSON.parse(File.readFrom("DLS/备份.json")).自动备份);
    fm.addInput("保存文件名"," ",JSON.parse(File.readFrom("DLS/备份.json")).保存文件名);
    fm.addInput("备份保留数量"," ",JSON.parse(File.readFrom("DLS/备份.json")).备份保留数量.toString());
    fm.addSwitch("7z压缩",z7);
    player.sendForm(fm,(player,data)=>{
        if(data!=null){
            let write = JSON.parse(File.readFrom("DLS/备份.json"))
            write.自动备份=data[0];
            write.保存文件名=data[1];
            write.备份保留数量=Number(data[2]);
            File.writeTo("DLS/备份.json",JSON.stringify(write,null,4).replace("\"7z压缩\": "+z7.toString(),"\"7z压缩\": "+data[3]));//需要加容错
        }
        mainmenu(player);
    })   
}